using System.Collections.Generic;
using Entitas;

public class ChangeHpSystem : ReactiveSystem<LogicEntity>
{
    LogicContext mContext;

    public ChangeHpSystem(LogicContext contexts) : base(contexts)
    {
        mContext = contexts;
    }

    protected override ICollector<LogicEntity> GetTrigger(IContext<LogicEntity> context)
    {
        return context.CreateCollector(LogicMatcher.Hp.Added());
    }

    protected override bool Filter(LogicEntity entity)
    {
        return true;
    }

    protected override void Execute(List<LogicEntity> entities)
    {
        foreach (var e in entities)
        {
            if (e.hp.Value == 0)
                e.ReplaceDestroyCell(20, 0);
        }
    }
}